package com.glsc.ngateway.common.base.domain.mysql.opmanagemain.ledger;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.*;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.List;

/**
 * @author liwei
 * 台账主表
 */
@Data
@Entity
@Table(name = "t_business_ledger")
@org.hibernate.annotations.Table(appliesTo = "t_business_ledger", comment = "台账主表")
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties({"hibernateLazyInitializer", "handler"})
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class BusinessLedger implements Serializable {
    private static final long serialVersionUID = 2051916036596605360L;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id", columnDefinition = "int(20) comment '台账id'")
    private Integer id;

    @ApiModelProperty(value = "台账名称")
    @Column(name = "name", columnDefinition = "varchar(255) COMMENT '台账名称'")
    private String name;

    @ApiModelProperty(value = "台账类型模板名称")
    @Column(name = "template_name", columnDefinition = "varchar(200) COMMENT '台账类型模板名称'")
    private String templateName;

    @Column(name = "ledger_template_id", columnDefinition = "int(20) comment '台账模板id'")
    private Integer ledgerTemplateId;

    @ApiModelProperty(value = "备注")
    @Column(name = "memo", columnDefinition = "varchar(255) COMMENT '备注'")
    private String memo;

    @Column(name = "create_id", columnDefinition = "int DEFAULT NULL COMMENT '创建人id'")
    @ApiModelProperty(value = "创建人id")
    private Long createId;

    @ApiModelProperty(value = "创建人名称")
    @Column(name = "create_name", columnDefinition = "varchar(100) COMMENT '创建人名称'")
    private String createName;

    @ApiModelProperty(value = "创建时间 yyyy-MM-dd HH:mm:ss")
    @Column(name = "create_time", columnDefinition = "datetime comment '创建时间'", updatable = false)
    @org.hibernate.annotations.CreationTimestamp
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    private LocalDateTime createTime;

    @Column(name = "status", columnDefinition = "varchar(20) COMMENT '任务状态,0待完成,1已完成  字典 t_deal_finish_state'")
    @ApiModelProperty(value = "任务状态")
    private String status;

    @Column(name = "finish_id", columnDefinition = "int DEFAULT NULL COMMENT '完成人id'")
    @ApiModelProperty(value = "完成人id")
    private Long finishId;

    @ApiModelProperty(value = "完成人名称")
    @Column(name = "finish_user_name", columnDefinition = "varchar(100) COMMENT '备注'")
    private String finishUserName;

    @Column(name = "to_task_type", columnDefinition = "varchar(40) COMMENT '待办任务类型,数据字典t_opmanage_task_type'")
    @ApiModelProperty(value = "待办任务类型")
    private String toTaskType;


    @ApiModelProperty(value = "台账完成时间 yyyy-MM-dd ")
    @Column(name = "finish_time", columnDefinition = "varchar(100) COMMENT '台账完成时间 yyyy-MM-dd'")
    private String finishTime;


    //任务列表
    @Transient
    private List<BusinessLedgerTask> taskList;

}
